<?php
namespace Management\Controller;
use Think\Controller;
use Myself\FileSystem;
class AtmClassController extends BaseController {

	 protected $m = NULL;
	 protected $m_atm = NULL;
	 protected $showType = NULL;

	 public function _initialize(){
	 		parent::_initialize();
			$this->m = M('atm_class');	
			$this->m_atm = M('atm');	
			$this->showType = C('ATM');	
	 }




    public function index(){
		header('Content-Type:text/html;charset=utf-8');
		
		$where['parent_id'] = I('parentid',0,'int');
		$where['id'] = array('NOT IN','8,9,10,11');
		
		$list = $this->m->where($where)->order('list_order desc, id asc')->select();
		if($where['parent_id'] && !$list){
			$this->error('没有相关信息，正在返回...',U('AtmClass/index'));
		}
		foreach($list as $key=>$item){
			$list[$key]["is_child"]=$this->m->where('parent_id='.$item["id"])->getField('count(*)');
			$list[$key]["atm_count"]=$this->m_atm->where('class_id='.$item["id"].' and language="'.cookie('AUTH_USER_LANG').'"')->getField('count(*)');
		}
		
		
		
		$this->assign('parentid',$where['parent_id']);// 赋值
		
		
		$this->assign('list',$list);// 赋值
		$this->assign('showType',$this->showType);// 赋值
		
		$this->display('Atm/class');
    }
	
	public function view(){
		header('Content-Type:text/html;charset=utf-8');
		$back_url=$_SERVER['HTTP_REFERER'];
		$id = I('id',0,"int");
		$this->assign('statusArr',$this->statusArr);// 状态
		
		$dataInfo = $this->m->find($id);
		$this->assign('dataInfo',$dataInfo);// 赋值
		$this->assign('back_url',$back_url);// 返回的url
		$this->display('Atm/class_edit');
	}
	
	
	
	
	
}